package jnpf.engine.custom.cmd.execution;

import org.flowable.common.engine.impl.interceptor.Command;
import org.flowable.common.engine.impl.interceptor.CommandContext;
import org.flowable.engine.impl.persistence.entity.ExecutionEntity;
import org.flowable.engine.impl.persistence.entity.ExecutionEntityManager;
import org.flowable.engine.impl.util.CommandContextUtil;

public class GetRootExecutionEntityCmd implements Command<ExecutionEntity> {

    protected String executionId;
    protected String currentTaskDefinitionKey;

    public GetRootExecutionEntityCmd(String executionId, String currentTaskDefinitionKey) {
        this.executionId = executionId;
        this.currentTaskDefinitionKey = currentTaskDefinitionKey;
    }

    @Override
    public ExecutionEntity execute(CommandContext commandContext) {
        ExecutionEntityManager executionEntityManager = CommandContextUtil.getExecutionEntityManager();
        ExecutionEntity subP = executionEntityManager.findById(executionId);
        ExecutionEntity parent = subP.getParent();
        return parent;
    }
}
